package com.platform.usercenter.domain.vo;

import cn.hutool.core.collection.CollectionUtil;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.platform.common.core.annotation.Excel;
import com.platform.common.core.domain.entity.SysUser;
import com.platform.constants.SysUserConstants;
import com.platform.usercenter.domain.SysOrganization;
import com.platform.usercenter.domain.SysOrganizationDept;
import com.platform.usercenter.service.TreeAdapter;
import lombok.Data;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @Author: 可乐
 * @Description:
 * @CreateTime: 2023-10-19  13:41
 */
@Data
public class SysUserOrgTreeVO implements TreeAdapter {

	/**
	 * 父节点
	 */
	private Long parentId;
	/**
	 * 类型 1 组织 2部门 3岗位
	 */
	private String treeType = SysUserConstants.TYPE_ORG;

	/** 子组织 */
	private List<SysUserOrgTreeVO> children = new ArrayList<SysUserOrgTreeVO>();

	/**
	 * 部门列表
	 */
	private List<SysOrganizationDept> sysOrganizationDepts;

	/** 组织ID */
	private Long orgId;

	/** 组织名称 */
	private String orgName;

	/** 显示顺序 */
	private Long orderNum;

	/** 是否删除(Y,N) */
	private String isDelete;

	/** 删除人 */
	private String deleteBy;

	/** 删除时间 */
	private Date deleteTime;

	/** 负责人 */
	private String leader;

	/** 联系电话 */
	private String phone;

	/** 邮箱 */
	private String email;

	/** 组织状态:0正常,1停用 */
	private String status;

	@Override
	public Long getTreeCurrentId() {
		return orgId;
	}

	@Override
	public Long getTreeParentId() {
		return parentId;
	}

	@Override
	public <T> void setTreeChildren(List<TreeAdapter> list, Class<T> clazz) {
		if (this.getClass().isAssignableFrom(clazz) && CollectionUtil.isNotEmpty(list)) {
			List<SysUserOrgTreeVO> collect = list.stream().map(SysUserOrgTreeVO.class::cast).collect(Collectors.toList());
			this.setChildren(collect);
		}
	}
}
